clear all;

figure('color',[1,1,1],'position',[20,40,1200,720]);

colors(1:6,1:3)=0; % < -10, -10 ~ 0, 0 ~ 10, 10 ~ 20, 20 ~ 30, > 30
colors(1,:)=[240,188,156]/256;
colors(2,:)=[255,235,214]/256;
colors(3,:)=[182,237,240]/256;
colors(4,:)=[116,180,232]/256;
colors(5,:)=[74,156,228]/256;
colors(6,:)=[31,131,224]/256;
% colors(5,:)=[31,131,224]/256;
% colors(6,:)=[29,68,184]/256;
%% 1
subplot(2,3,1);
load('baseline\baselineA.mat');
xlim([0,40]);
ylim([1,2.5]);
yticks(1:0.5:2)
hold on;
axis on;
grid off;
axis square;
patch([0,50,50,0],[1,1,2.6,2.6],colors(3,:)) % fill color
hold on
plot(x3,y3,'-k');
patch([0,x3,40,41],[2.6,y3,2.10889,2.6],colors(4,:)) % fill color
plot(x2,y2,'-k');
patch([x2,41],[y2,2.6],colors(5,:))
plot(x1,y1,'-k');
patch(x1,y1,colors(6,:))

plot(x4(1:end-1),y4(1:end-1),'-k');
patch(x4,y4,colors(4,:))
plot(x6(1:end-1),y6(1:end-1),'-k');
patch(x6,y6,colors(5,:))

plot([0,40],[1,1],'-k')

title( 'A. Branch opened in 90 (model)', 'FontSize',15,'Interpreter','Latex');
xlabel('total wealth $m_t + a_t$', 'FontSize',12,'Interpreter','Latex');
ylabel('talent $z_t$', 'FontSize',12,'Interpreter','Latex');
xlim([0,40])
set(gca,'FontSize',12);
a=text(20, 2.35, '30','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',20)
a=text(20, 2.05, '20','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(15, 1.97, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',10)
a=text(15, 1.29, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',10)
a=text(22, 1.16, '20','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',10)



%% 2
subplot(2,3,4);
load('baseline\baselineB.mat');
xlim([0,40]);
ylim([1,2.5]);
yticks(1:0.5:2)
hold on;
axis on;
grid off;
axis square;
patch([0,50,50,0],[1,1,2.6,2.6],colors(3,:))
hold on
plot(x1,y1,'-k');
patch(x1,y1,colors(2,:))
plot(x2(1:end-1),y2(1:end-1),'-k');
patch(x2,y2,colors(4,:))

title( 'D. With a branch in 86 (model)', 'FontSize',15,'Interpreter','Latex');
xlabel('total wealth $m_t + a_t$', 'FontSize',12,'Interpreter','Latex');
ylabel('talent $z_t$', 'FontSize',12,'Interpreter','Latex');
set(gca,'FontSize',12);
a=text(20, 2.33, '0','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(27, 1.28, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)


%% 3
subplot(2,3,2);
xlim([0,40]);
ylim([1,2.5]);
yticks(1:0.5:2)
hold on;
axis on;
grid off;
axis square;
patch([0,50,50,0],[1,1,2.6,2.6],colors(3,:))
hold on
load('credit/baselineA.mat');
plot(x3,y3,'-k');
patch([0,x3,40,41],[2.6,y3,2.13069,2.6],colors(4,:))
plot(x2,y2,'-k');
patch([x2,41],[y2,2.6],colors(5,:))
plot(x1,y1,'-k');
patch(x1,y1,colors(6,:))

plot([0,40],[1,1],'-k')


title( 'B. Branch opened in 90 (credit)', 'FontSize',15,'Interpreter','Latex');
xlabel('total wealth $m_t + a_t$', 'FontSize',12,'Interpreter','Latex');
ylabel('talent $z_t$', 'FontSize',12,'Interpreter','Latex');
xlim([0,40])
set(gca,'FontSize',12);
a=text(19, 2.42, '30','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(19, 2.14, '20','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(19, 2.05, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)



%% 4
subplot(2,3,5)
xlim([0,40]);
ylim([1,2.5]);
yticks(1:0.5:2)
hold on;
axis on;
grid off;
axis square;
patch([0,50,50,0],[1,1,2.6,2.6],colors(3,:))
hold on
load('credit\baselineB.mat');
plot(x1,y1,'-k');
patch([x1,40,41],[y1,2.43634,2.6],colors(2,:))
plot(x2(1:end-1),y2(1:end-1),'-k');
patch(x2,y2,colors(4,:))

title( 'E. With a branch in 86 (credit)', 'FontSize',15,'Interpreter','Latex');
xlabel('total wealth $m_t + a_t$', 'FontSize',12,'Interpreter','Latex');
ylabel('talent $z_t$', 'FontSize',12,'Interpreter','Latex');
set(gca,'FontSize',12);
a=text(19, 2.27, '0','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(27, 1.35, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)



%% 5
subplot(2,3,3)
xlim([0,40]);
ylim([1,2.5]);
yticks(1:0.5:2)
hold on;
axis on;
grid off;
axis square;
patch([0,50,50,0],[1,1,2.6,2.6],colors(3,:))
hold on
load('deposit\baselineA.mat');
plot(x4,y4,'-k');
patch([x4,41,41],[y4,1.4,0],colors(4,:))
plot(x6(1:end-1),y6(1:end-1),'-k');
patch(x6,y6,colors(5,:))

plot([0,40],[1,1],'-k')


title( 'C. Branch opened in 90 (deposit)', 'FontSize',15,'Interpreter','Latex');
xlabel('total wealth $m_t + a_t$', 'FontSize',12,'Interpreter','Latex');
ylabel('talent $z_t$', 'FontSize',12,'Interpreter','Latex');
xlim([0,40])
set(gca,'FontSize',12);
a=text(22, 1.24, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',10)
a=text(22, 1.1, '20','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',10)



%% 6
subplot(2,3,6)
xlim([0,40]);
ylim([1,2.5]);
yticks(1:0.5:2)
hold on;
axis on;
grid off;
axis square;
patch([0,50,50,0],[1,1,2.6,2.6],colors(2,:))
hold on
load('deposit\baselineB.mat');
plot(x4,y4,'-k');
patch([0,x4,40,41],[10,y4,2.11995,2.6],colors(3,:))
plot(x6(1:end-1),y6(1:end-1),'-k');
patch(x6,y6,colors(1,:))
plot(x3,y3,'-k');
patch([0,x3,45],[10,y3,2.6],colors(4,:))
title( 'F. With a branch in 86 (deposit)', 'FontSize',15,'Interpreter','Latex');
xlabel('total wealth $m_t + a_t$', 'FontSize',12,'Interpreter','Latex');
ylabel('talent $z_t$', 'FontSize',12,'Interpreter','Latex');
set(gca,'FontSize',12);
a=text(25, 1.75, '0','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(25, 2.29, '10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',15)
a=text(25, 1.11, '-10','color',[0 0 0], 'FontSize',10,'FontName','Helvetica');
set(a,'Rotation',10)

